home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2001 October
/
PCWorld_2001-10_cd.bin
/
Software
/
TemaCD
/
3dcanvas
/
3DCanv11.CAB
/
Shift Active Object.CS
< prev
next >
Wrap
Text File
|
2001-04-15
|
4KB
|
170 lines
Language = VBScript
'*********************************************************************************
' Purpose: Shifts an Object
'*********************************************************************************
Option Explicit 'require variable declarations
Sub Main (CanvasApp)
Dim Scene
Dim ActiveObjectCount
Dim ShiftX
Dim ShiftY
Dim ShiftZ
Dim NumericShiftX
Dim NumericShiftY
Dim NumericShiftZ
Dim Reply
'get the scene
Set Scene = CanvasApp.GetActiveScene
'get the active object count
ActiveObjectCount = Scene.GetActiveObjectCount
'only proceed if there is an active object
If ActiveObjectCount = 0 Then
MsgBox "Please select an object."
Else
'ask the user how much to shift the object
ShiftX = InputBox("X Shift?",,"0")
'if they entered anything
If ShiftX <> "" Then
'translate the entered string into a numeric value
On Error Resume Next
NumericShiftX = CSng(ShiftX)
Err.Clear
On Error Goto 0
ShiftY = InputBox("Y Shift?",,"0")
'if they entered anything
If ShiftY <> "" Then
'translate the entered string into a numeric value
On Error Resume Next
NumericShiftY = CSng(ShiftY)
Err.Clear
On Error Goto 0
ShiftZ = InputBox("Z Shift?",,"0")
'if they entered anything
If ShiftZ <> "" Then
'translate the entered string into a numeric value
On Error Resume Next
NumericShiftZ = CSng(ShiftZ)
Err.Clear
On Error Goto 0
'Ask them if they want to shift using world coordinates
Reply = MsgBox("Shift Using World Coordinates?", 3)
If Reply <> vbCancel Then
Shift Scene, NumericShiftX, NumericShiftY, NumericShiftZ, Reply
End if
End if
End if
End if
End If
End Sub
Sub Shift (Scene, ShiftX, ShiftY, ShiftZ, World)
Dim Object
Dim PointCount
Dim PointIndex
Dim PointX
Dim PointY
Dim PointZ
'get the active object (right now there can only be one)
Set Object = Scene.GetActiveObject(0)
'if they asked to shift in world coordinates, let's transform to world coordinates
If World = vbYes then
Object.Transform
End if
'get the number of points in the object
PointCount = Object.GetPointCount
'Run through the points shifting them
For PointIndex = 0 to PointCount - 1
'get the point
Object.GetPoint PointIndex, PointX, PointY, PointZ
'shift the point
PointX = PointX + ShiftX
PointY = PointY + ShiftY
PointZ = PointZ + ShiftZ
'set the point
Object.SetPoint PointIndex, PointX, PointY, PointZ
Next
'if they asked to shift in world coordinates, let's inverse transform to model coordinates
If World = vbYes then
Object.InverseTransform
End if
'finally write a Script operation layer to save the change
Object.WriteScriptOperationLayer
End Sub